package ru.stepuk.modern.nodes.buffers;

import java.util.Deque;
import java.util.LinkedList;
import javax.swing.ImageIcon;
import ru.stepuk.modern.Model;
import ru.stepuk.modern.Request;

/**
 *
 * @author ivan
 */
public class Queue extends Buffer {

    {
        icon = new ImageIcon(getClass().getResource("/images/b_queue.png"));
    }

    public Queue(Model model) {
        super(model);
        this.container = new LinkedList<Request>();
    }

    @Override
    public Request fetchRequest() {
        return ((Deque<Request>) container).pollFirst();
    }

    @Override
    public void putRequest(Request request) {
        if (!hasFreeSpace()) {
            return;
        } else {
            ((Deque<Request>) container).offerLast(request);
        }
    }

}
